//
//  DownloadImageOperation.m
//  TodayFirstNews
//
//  Created by 向祖华 on 16/3/3.
//  Copyright © 2016年 向祖华. All rights reserved.
//

#import "DownloadImageOperation.h"

@implementation DownloadImageOperation

-(void)main
{
    @autoreleasepool {
        //
        NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:self.url]];
        UIImage * image = [UIImage imageWithData:data];
        if (self.delegate && [self.delegate respondsToSelector:@selector(getImage:operation:imageTag:)]) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.delegate getImage:image operation:self imageTag:self.imageTage];
            });
        }
    }
}

@end
